//package com.ford.trade.controller;
//
//import com.ford.trade.dto.QueryDTO;
//import com.ford.trade.entity.Game;
//import com.ford.trade.processor.BeiDan500PeilvProcessor;
//import com.ford.trade.processor.TeamProcessor;
//import com.ford.trade.service.BeiDan500PeilvService;
//import com.ford.trade.service.Game500Service;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.util.CollectionUtils;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RestController;
//import us.codecraft.webmagic.Spider;
//import us.codecraft.webmagic.scheduler.BloomFilterDuplicateRemover;
//import us.codecraft.webmagic.scheduler.QueueScheduler;
//
//import javax.annotation.Resource;
//import java.text.ParseException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @author: ford
// * @date: 2022/9/12 14:44
// */
//@Slf4j
//@RestController
//public class BeiDan500Copntroller {
//
//    @Resource
//    private Game500Service game500Service;
//    @Resource
//    private BeiDan500PeilvService beiDan500PeilvService;
//
//    @PostMapping("/beidan/500")
//    public void getBisai(@RequestBody QueryDTO queryDTO) {
//        TeamProcessor teamProcessor = new TeamProcessor();
//        teamProcessor.setGameService(game500Service);
//        teamProcessor.setDate(queryDTO.getDate());
//        teamProcessor.setUrl(queryDTO.getUrl());
//        teamProcessor.setGetResult(queryDTO.getGetResult());
//        Spider.create(teamProcessor)
//                .addUrl(queryDTO.getUrl())
//                .setScheduler(new QueueScheduler().setDuplicateRemover(new BloomFilterDuplicateRemover(100)))
//                .thread(10)
//                .run();
//
//    }
//
//    @PostMapping("/beidan/500/getPeilv")
//    public void getPeilv(@RequestBody QueryDTO queryDTO) throws ParseException {
//        List<Game> allByDateAfter = game500Service.findAllByDateBetten(queryDTO.getDate());
//        if (CollectionUtils.isEmpty(allByDateAfter)) {
//            return;
//        }
//        List<String> urls = new ArrayList<>();
//        for (Game game : allByDateAfter) {
//            urls.add("https://odds.500.com/fenxi/ouzhi-" + game.getIndexId() + ".shtml" + "?ctype=1");
//        }
//        for (Game game : allByDateAfter) {
//            urls.add("https://odds.500.com/fenxi/ouzhi-" + game.getIndexId() + ".shtml" + "?order=0");
//
//        }
//        String[] objects = new String[allByDateAfter.size()];
//        String[] array = urls.toArray(objects);
//        BeiDan500PeilvProcessor peilvProcessor = new BeiDan500PeilvProcessor();
//        peilvProcessor.setCookie(queryDTO.getCookie());
//        peilvProcessor.setBeiDan500PeilvService(beiDan500PeilvService);
//        peilvProcessor.setDate(queryDTO.getDate());
//        Spider.create(peilvProcessor)
//                .addUrl(array)
//                .setScheduler(new QueueScheduler().setDuplicateRemover(new BloomFilterDuplicateRemover(100)))
//                .thread(32)
//                .run();
//    }
//
//}
